package xiao_jin.fantastic_journey.core.common.entity.client;

import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import software.bernie.geckolib.animation.AnimationState;
import software.bernie.geckolib.cache.object.GeoBone;
import software.bernie.geckolib.constant.DataTickets;
import software.bernie.geckolib.model.GeoModel;
import software.bernie.geckolib.model.data.EntityModelData;
import xiao_jin.fantastic_journey.core.common.entity.custom.MonsterEyeEntity;
import xiao_jin.fantastic_journey.util.ModUtil;

public class MonsterEyeModel extends GeoModel<MonsterEyeEntity> {
    public Identifier getModelResource(MonsterEyeEntity object) {
        return ModUtil.getIdOfMod("geo/monster_eye.geo.json");
    }

    public Identifier getTextureResource(MonsterEyeEntity object) {
        return ModUtil.getIdOfMod("textures/item/monster_eye_egg.png");
    }

    public Identifier getAnimationResource(MonsterEyeEntity object) {
        return ModUtil.getIdOfMod("animations/monster_eye.animation.json");
    }

    public void setCustomAnimations(MonsterEyeEntity animatable, long instanceId, AnimationState<MonsterEyeEntity> animationState) {
        GeoBone head = getAnimationProcessor().getBone("monster_eye");
        if (head != null) {
            EntityModelData entityData = animationState.getData(DataTickets.ENTITY_MODEL_DATA);
            head.setRotX(entityData.headPitch() * MathHelper.RADIANS_PER_DEGREE);
            head.setRotY(entityData.netHeadYaw() * MathHelper.RADIANS_PER_DEGREE);
        }
    }
}